package top.zhan.prototype;

/**
 * @author Zhan
 * @date 2022/9/27 14:24
 */
public class Client {

    public static void main(String[] args) throws CloneNotSupportedException {
        Person person1 = new Person();
        person1.setAge(10);
        person1.setName("小滴课堂-老王");
        person1.getList().add("aaa");
        person1.getList().add("bbb");
        // 浅拷贝
//        Person person2 = person1.clone();
        Person person2 = person1.deepClone();
        person2.setName("Anna");
        person2.getList().add("ccc");
        System.out.println("person1=" + person1.getName() + ", age=" + person1.getAge());
        System.out.println("person2=" + person2.getName() + ", age=" + person2.getAge());
    }
}
